package com.presto.directo.mvvm.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.presto.directo.R
import com.presto.directo.entity.UserCardEntity

class CardListAdapter(layoutResId: Int, private val showSelector: Boolean) : BaseQuickAdapter<UserCardEntity, BaseViewHolder>(layoutResId) {

    var index = -1

    override fun convert(holder: BaseViewHolder, item: UserCardEntity) {
        holder.setText(R.id.tv_type, if (item.card_type == "1") CARD_TYPES[0] else CARD_TYPES[1])
        holder.setText(R.id.tv_bank, item.bank_code)
        holder.setText(R.id.tv_card_no, item.card_no)
        holder.setGone(R.id.iv_select, !showSelector)
        holder.setImageResource(R.id.iv_select, if (holder.layoutPosition == index) R.mipmap.icon_cb_checked else R.mipmap.icon_cb_unchecked)
        holder.setBackgroundResource(R.id.ll_card, if (item.card_type == "1") R.mipmap.bg_bank_card1 else R.mipmap.bg_bank_card2)

    }

}

val CARD_TYPES = listOf("CLABE", "Tarjeta de débito")